package cn.gailvlun.gll.presentation.wish.maker;

import android.content.Context;
import android.content.Intent;
import android.databinding.DataBindingUtil;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.text.Html;
import android.text.Spanned;
import android.view.View;

import cn.gailvlun.gll.R;
import cn.gailvlun.gll.databinding.ActivityWishExplainBinding;
import cn.gailvlun.gll.presentation.base.App;
import cn.gailvlun.gll.presentation.base.BaseActivity;
import cn.gailvlun.gll.util.SPUtil;



public class WishExplainActivity extends BaseActivity {

    private boolean extraHideButton;
    private ActivityWishExplainBinding mBinding;

    public static void openActivity(Context context) {
        Intent intent = new Intent(context, WishExplainActivity.class);
        context.startActivity(intent);
    }

    public static void openActivity(Context context, boolean hide) {
        Intent intent = new Intent(context, WishExplainActivity.class);
        intent.putExtra("extra_hide_button", hide);
        context.startActivity(intent);
    }

    @Override
    protected void initComponent() {
        mBinding = DataBindingUtil.setContentView(this, R.layout.activity_wish_explain);
        mBinding.setPresenter(new Presenter());
    }

    @Override
    protected void createHandler() {
    }

    @Override
    protected void loadData(@Nullable Bundle savedInstanceState) {
        extraHideButton = getIntent().getBooleanExtra("extra_hide_button", false);
        if (extraHideButton) {
            mBinding.tvMakeWish.setVisibility(View.GONE);
        }
    }

    public class Presenter {
        public void onAgree() {
            SPUtil.put(SPUtil.USER, "wishExplain", true);
            MakeWishActivity.openActivity(mContext);
            finish();
        }
    }

    public static class Util {
        public static Spanned getExplainContent() {
            return Html.fromHtml(App.getInstance().getResources().getString(R.string.wish_explain_content));
        }
    }
}
